```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring自定义注解与AOP深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-self;
            color: #333;
            line-height: 1.8;
            background-color: #f9fafb;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
        .code-block {
            background-color: #282c34;
            color: #abb2bf;
            border-radius: 8px;
            position: relative;
        }
        .copy-btn {
            position: absolute;
            top: 10px;
            right: 10px;
            background: rgba(255,255,255,0.1);
            border: none;
            color: white;
            padding: 2px 8px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s;
        }
        .copy-btn:hover {
            background: rgba(255,255,255,0.2);
        }
        .card {
            transition: transform 0.3s, box-shadow 0.3s;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight {
            position: relative;
        }
        .highlight:before {
            content: '';
            position: absolute;
            left: -4px;
            top: 0;
            height: 100%;
            width: 4px;
            background: linear-gradient(to bottom, #667eea, #764ba2);
            border-radius: 4px;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero min-h-screen flex items-center py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 leading-tight" style="font-family: 'Noto Serif SC'">
                    Spring自定义注解与AOP深度解析
                </h1>
                <p class="text-xl md:text-2xl mb-10 opacity-90">
                    探索Java元编程的强大能力，打造优雅高效的Spring应用
                </p>
                <div class="flex justify-center space-x-4">
                    <a href="#intro" class="px-8 py-3 bg-white text-indigo-700 font-semibold rounded-lg hover:shadow-lg transition-all duration-300">
                        开始探索 <i class="fas fa-arrow-down ml-2"></i>
                    </a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-4 py-16 max-w-5xl">
        <!-- Introduction -->
        <section id="intro" class="mb-20">
            <h2 class="text-3xl font-bold mb-6 text-gray-800" style="font-family: 'Noto Serif SC'">
                <i class="fas fa-star text-yellow-400 mr-3"></i> 自定义注解与AOP的核心价值
            </h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-8 rounded-xl shadow-md card">
                    <div class="text-indigo-600 mb-4 text-4xl">
                        <i class="fas fa-tags"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">声明式编程</h3>
                    <p class="text-gray-600">通过简单的注解标记，减少样板代码，使业务逻辑更清晰，提高代码可读性和可维护性。</p>
                </div>
                <div class="bg-white p-8 rounded-xl shadow-md card">
                    <div class="text-indigo-600 mb-4 text-4xl">
                        <i class="fas fa-project-diagram"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">横切关注点</h3>
                    <p class="text-gray-600">将日志、事务、安全等横切关注点与业务逻辑分离，实现关注点分离的编程范式。</p>
                </div>
            </div>
        </section>

        <!-- Section 1 -->
        <section class="mb-20">
            <div class="flex items-center mb-6">
                <span class="text-indigo-600 bg-indigo-100 rounded-full w-10 h-10 flex items-center justify-center font-bold mr-4">1</span>
                <h2 class="text-3xl font-bold text-gray-800" style="font-family: 'Noto Serif SC'">自定义注解的定义</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-6">
                    <p class="mb-6 text-gray-700">
                        自定义注解是 Java 中的一种元数据标记，允许在代码中添加自定义信息，并能通过反射机制进行处理。我们首先定义一个自定义注解，然后在 Spring 中使用该注解来标识需要处理的类或方法。
                    </p>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800 highlight pl-6">
                        <i class="fas fa-code text-indigo-500 mr-2"></i> 示例：定义一个简单的自定义注解 <code>@LogExecutionTime</code>
                    </h3>
                    
                    <div class="code-block mb-8">
                        <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                        <pre><code class="language-java">@Target(ElementType.METHOD)  // 该注解只用于方法上
@Retention(RetentionPolicy.RUNTIME)  // 注解在运行时可用
public @interface LogExecutionTime {
}</code></pre>
                    </div>
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div class="bg-indigo-50 p-4 rounded-lg">
                            <div class="flex items-center mb-2">
                                <i class="fas fa-info-circle text-indigo-600 mr-2"></i>
                                <h4 class="font-semibold text-gray-800">@Target(ElementType.METHOD)</h4>
                            </div>
                            <p class="text-gray-700 text-sm">表示该注解只能应用于方法上</p>
                        </div>
                        <div class="bg-indigo-50 p-4 rounded-lg">
                            <div class="flex items-center mb-2">
                                <i class="fas fa-info-circle text-indigo-600 mr-2"></i>
                                <h4 class="font-semibold text-gray-800">@Retention(RetentionPolicy.RUNTIME)</h4>
                            </div>
                            <p class="text-gray-700 text-sm">表示该注解会在运行时通过反射获取</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 2 -->
        <section class="mb-20">
            <div class="flex items-center mb-6">
                <span class="text-indigo-600 bg-indigo-100 rounded-full w-10 h-10 flex items-center justify-center font-bold mr-4">2</span>
                <h2 class="text-3xl font-bold text-gray-800" style="font-family: 'Noto Serif SC'">自定义注解的处理器设计</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <p class="mb-6 text-gray-700">
                        自定义注解通常需要一个处理器来执行特定的操作，例如记录日志、验证权限等。在 Spring 中，我们通常使用 <strong>AOP</strong> 来处理注解。
                    </p>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800 highlight pl-6">
                        <i class="fas fa-cogs text-indigo-500 mr-2"></i> 实现步骤
                    </h3>
                    
                    <div class="flex flex-col space-y-4 mb-8">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 mt-1">
                                <i class="fas fa-check text-xs"></i>
                            </div>
                            <p class="text-gray-700">定义一个切面类</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 mt-1">
                                <i class="fas fa-check text-xs"></i>
                            </div>
                            <p class="text-gray-700">在切面类中定义一个通知方法，监听被自定义注解标注的方法</p>
                        </div>
                        <div class="flex items-start">
                            <div class="flex-shrink-0 bg-indigo-100 text-indigo-600 rounded-full w-6 h-6 flex items-center justify-center mr-3 mt-1">
                                <i class="fas fa-check text-xs"></i>
                            </div>
                            <p class="text-gray-700">使用 Spring AOP 来处理注解的逻辑</p>
                        </div>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800 highlight pl-6">
                        <i class="fas fa-code text-indigo-500 mr-2"></i> 示例：定义一个处理 <code>@LogExecutionTime</code> 注解的切面
                    </h3>
                    
                    <div class="code-block mb-8">
                        <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                        <pre><code class="language-java">@Aspect
@Component
public class LogExecutionTimeAspect {

    @Around("@annotation(LogExecutionTime)")  // 通过注解进行方法拦截
    public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
        long start = System.currentTimeMillis();  // 记录方法执行前的时间
        Object result = joinPoint.proceed();  // 执行目标方法
        long end = System.currentTimeMillis();  // 记录方法执行后的时间

        // 输出方法执行时间
        System.out.println("Execution time of " + joinPoint.getSignature() + " is " + (end - start) + "ms");
        return result;
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 3 -->
        <section class="mb-20">
            <div class="flex items-center mb-6">
                <span class="text-indigo-600 bg-indigo-100 rounded-full w-10 h-10 flex items-center justify-center font-bold mr-4">3</span>
                <h2 class="text-3xl font-bold text-gray-800" style="font-family: 'Noto Serif SC'">注解处理器与AOP配合</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <p class="mb-6 text-gray-700">
                        在 Spring 中，注解的处理通常与 AOP（面向切面编程）一起使用，Spring 会根据注解类型动态生成代理对象，拦截带有注解的目标方法，并在方法执行前后执行增强逻辑。
                    </p>
                    
                    <div class="flex items-center bg-blue-50 border-l-4 border-blue-500 p-4 mb-6 rounded-r">
                        <i class="fas fa-lightbulb text-blue-500 mr-3 text-2xl"></i>
                        <p class="text-blue-800">Spring AOP 会根据注解和方法匹配来确定何时执行通知。</p>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800 highlight pl-6">
                        <i class="fas fa-code text-indigo-500 mr-2"></i> 核心源码解析：<code>@Around</code> 注解的工作原理
                    </h3>
                    
                    <div class="code-block mb-8">
                        <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                        <pre><code class="language-java">@Around("@annotation(LogExecutionTime)")  // 注解拦截器的核心实现
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
    // 记录执行开始时间
    long start = System.currentTimeMillis();

    // 执行目标方法
    Object result = joinPoint.proceed();

    // 记录执行结束时间
    long end = System.currentTimeMillis();

    // 输出方法的执行时间
    System.out.println("Execution time of " + joinPoint.getSignature() + " is " + (end - start) + "ms");
    return result;
}</code></pre>
                    </div>
                    
                    <div class="bg-gray-50 p-4 rounded-lg mb-6">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 text-indigo-500 mr-3 mt-1">
                                <i class="fas fa-arrow-right"></i>
                            </div>
                            <p class="text-gray-700"><code>joinPoint.proceed()</code>：表示调用目标方法，<code>ProceedingJoinPoint</code> 是 <code>JoinPoint</code> 的子类，支持方法的继续执行。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 4 -->
        <section class="mb-20">
            <div class="flex items-center mb-6">
                <span class="text-indigo-600 bg-indigo-100 rounded-full w-10 h-10 flex items-center justify-center font-bold mr-4">4</span>
                <h2 class="text-3xl font-bold text-gray-800" style="font-family: 'Noto Serif SC'">启动Spring AOP的配置</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <p class="mb-6 text-gray-700">
                        为了使得 Spring 能够识别自定义注解并使用切面进行处理，需要确保 AOP 功能已经启用。Spring 提供了两种启用 AOP 的方式：
                    </p>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-8">
                        <div class="bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-file-code text-green-500 mr-2"></i> 使用 XML 配置文件
                            </h4>
                            <div class="code-block">
                                <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                                <pre><code class="language-xml">&lt;aop:aspectj-autoproxy/&gt;</code></pre>
                            </div>
                        </div>
                        <div class="bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-at text-purple-500 mr-2"></i> 使用注解 <code>@EnableAspectJAutoProxy</code>
                            </h4>
                            <div class="code-block">
                                <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                                <pre><code class="language-java">@Configuration
@EnableAspectJAutoProxy  // 启用 Spring AOP 功能
public class AppConfig {
}</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 5 -->
        <section class="mb-20">
            <div class="flex items-center mb-6">
                <span class="text-indigo-600 bg-indigo-100 rounded-full w-10 h-10 flex items-center justify-center font-bold mr-4">5</span>
                <h2 class="text-3xl font-bold text-gray-800" style="font-family: 'Noto Serif SC'">自定义注解的处理器与Spring容器集成</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <p class="mb-6 text-gray-700">
                        Spring 容器负责创建所有的 bean，包括自定义的注解处理器。为了确保自定义注解处理器能够生效，我们需要将其作为 Spring 的一个组件 (<code>@Component</code>) 放入 Spring 容器管理。
                    </p>
                    
                    <div class="code-block mb-8">
                        <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                        <pre><code class="language-java">@Aspect
@Component  // 注册为 Spring 管理的 bean
public class LogExecutionTimeAspect {
    @Around("@annotation(LogExecutionTime)")  // 监听 @LogExecutionTime 注解的方法
    public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
        long start = System.currentTimeMillis();
        Object result = joinPoint.proceed();
        long end = System.currentTimeMillis();
        System.out.println("Execution time of " + joinPoint.getSignature() + " is " + (end - start) + "ms");
        return result;
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 6 -->
        <section class="mb-20">
            <div class="flex items-center mb-6">
                <span class="text-indigo-600 bg-indigo-100 rounded-full w-10 h-10 flex items-center justify-center font-bold mr-4">6</span>
                <h2 class="text-3xl font-bold text-gray-800" style="font-family: 'Noto Serif SC'">注解处理器的执行顺序</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <p class="mb-6 text-gray-700">
                        Spring AOP 会在执行目标方法之前和之后进行插入。处理器的执行顺序和 Spring AOP 的代理顺序密切相关。如果有多个 <code>@Aspect</code> 注解的切面类，Spring 会根据配置的顺序来决定它们的执行顺序。
                    </p>
                    
                    <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-6 rounded-r">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fas fa-exclamation-circle text-yellow-500"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-yellow-700">
                                    <strong>注意：</strong> 如果使用了 <code>@Order</code> 注解，还可以指定处理器的优先级。默认情况下，AOP 的执行顺序是按照 Spring Bean 的加载顺序来执行。
                                </p>
                            </div>
                        </div>
                    </div>
                    
                    <h3 class="text-xl font-semibold mb-4 text-gray-800 highlight pl-6">
                        <i class="fas fa-sort-numeric-down text-indigo-500 mr-2"></i> 示例：通过 <code>@Order</code> 控制切面的执行顺序
                    </h3>
                    
                    <div class="code-block mb-8">
                        <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                        <pre><code class="language-java">@Aspect
@Component
@Order(1)  // 设置优先级，数字越小，优先级越高
public class LogExecutionTimeAspect {
    // 切面代码...
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 7 -->
        <section class="mb-20">
            <div class="flex items-center mb-6">
                <span class="text-indigo-600 bg-indigo-100 rounded-full w-10 h-10 flex items-center justify-center font-bold mr-4">7</span>
                <h2 class="text-3xl font-bold text-gray-800" style="font-family: 'Noto Serif SC'">综合示例</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <p class="mb-6 text-gray-700">
                        下面是一个完整的示例，演示如何创建自定义注解和处理器，并在 Spring Boot 项目中进行集成。
                    </p>
                    
                    <div class="grid md:grid-cols-3 gap-6 mb-8">
                        <div class="bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-tag text-indigo-500 mr-2"></i> 自定义注解定义
                            </h4>
                            <div class="code-block">
                                <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                                <pre><code class="language-java">@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface LogExecutionTime {
}</code></pre>
                            </div>
                        </div>
                        <div class="bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-project-diagram text-green-500 mr-2"></i> AOP 切面定义
                            </h4>
                            <div class="code-block">
                                <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                                <pre><code class="language-java">@Aspect
@Component
public class LogExecutionTimeAspect {

    @Around("@annotation(LogExecutionTime)")
    public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
        long start = System.currentTimeMillis();
        Object result = joinPoint.proceed();
        long end = System.currentTimeMillis();
        System.out.println("Execution time of " + joinPoint.getSignature() + " is " + (end - start) + "ms");
        return result;
    }
}</code></pre>
                            </div>
                        </div>
                        <div class="bg-white border border-gray-200 rounded-lg p-6 shadow-sm">
                            <h4 class="font-semibold text-lg mb-3 text-gray-800 flex items-center">
                                <i class="fas fa-laptop-code text-blue-500 mr-2"></i> 应用实例
                            </h4>
                            <div class="code-block">
                                <button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> 复制</button>
                                <pre><code class="language-java">@RestController
public class MyController {

    @LogExecutionTime  // 使用自定义注解
    @GetMapping("/hello")
    public String hello() {
        return "Hello, Spring AOP!";
    }
}</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mb-20">
            <div class="bg-gradient-to-br from-indigo-50 to-purple-50 rounded-xl p-8">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 text-center" style="font-family: 'Noto Serif SC'">
                    <i class="fas fa-lightbulb text-indigo-500 mr-3"></i> 关键要点总结
                </h2>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h3 class="font-semibold text-lg mb-3 text-indigo-600 flex items-center">
                            <i class="fas fa-check-circle mr-2"></i> 自定义注解最佳实践
                        </h3>
                        <ul class="space-y-2 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mr-2 mt-1"></i>
                                <span>合理选择<code>@Target</code>和<code>@Retention</code>策略</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mr-2 mt-1"></i>
                                <span>为注解添加清晰的文档说明</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mr-2 mt-1"></i>
                                <span>保持注解的单一职责原则</span>
                            </li>
                        </ul>
                    </div>
                    <div class="bg-white p-6 rounded-lg shadow-sm">
                        <h3 class="font-semibold text-lg mb-3 text-indigo-600 flex items-center">
                            <i class="fas fa-project-diagram mr-2"></i> AOP 设计建议
                        </h3>
                        <ul class="space-y-2 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mr-2 mt-1"></i>
                                <span>使用<code>@Order</code>控制切面执行顺序</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mr-2 mt-1"></i>
                                <span>避免在切面中处理过多业务逻辑</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mr-2 mt-1"></i>
                                <span>合理处理切面中的异常情况</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12">
        <div class="container mx-auto px-4">
            <div class="flex flex-col items-center">
                <div class="text-2xl font-semibold mb-4">技术小馆</div>
                <div class="mb-6 text-gray-400">
                    <a href="http://www.yuque.com/jtostring" class="hover:text-white transition-colors">
                        <i class="fas fa-globe mr-2"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
                <div class="flex space-x-6">
                    <a href="#" class="text-gray-400 hover:text-white transition-colors">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition-colors">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition-colors">
                        <i class="fab fa-weixin text-xl"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        // 初始化Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 复制代码功能
        function copyCode(button) {
            const codeBlock = button.parentNode;
            const code = codeBlock.querySelector('code').innerText;
            navigator.clipboard.writeText(code).then(() => {
                const originalText = button.innerHTML;
                button.innerHTML = '<i class="fas fa-check"></i> 已复制';
                setTimeout(() => {
                    button.innerHTML = originalText;
                }, 2000);
            });
        }
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```